package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ErpInventoryTransferDetail;
import com.ruoyi.service.IErpInventoryTransferDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调拨明细管理Controller
 * 
 * @author zhp
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/storage/allotDetail")
public class ErpInventoryTransferDetailController extends BaseController
{
    @Autowired
    private IErpInventoryTransferDetailService erpInventoryTransferDetailService;

    /**
     * 查询调拨明细管理列表
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpInventoryTransferDetail erpInventoryTransferDetail)
    {
        startPage();
        List<ErpInventoryTransferDetail> list = erpInventoryTransferDetailService.selectErpInventoryTransferDetailList(erpInventoryTransferDetail);
        return getDataTable(list);
    }

    /**
     * 导出调拨明细管理列表
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:export')")
    @Log(title = "调拨明细管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpInventoryTransferDetail erpInventoryTransferDetail)
    {
        List<ErpInventoryTransferDetail> list = erpInventoryTransferDetailService.selectErpInventoryTransferDetailList(erpInventoryTransferDetail);
        ExcelUtil<ErpInventoryTransferDetail> util = new ExcelUtil<ErpInventoryTransferDetail>(ErpInventoryTransferDetail.class);
        util.exportExcel(response, list, "调拨明细管理数据");
    }

    /**
     * 获取调拨明细管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(erpInventoryTransferDetailService.selectErpInventoryTransferDetailById(id));
    }

    /**
     * 新增调拨明细管理
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:add')")
    @Log(title = "调拨明细管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpInventoryTransferDetail erpInventoryTransferDetail)
    {
        return toAjax(erpInventoryTransferDetailService.insertErpInventoryTransferDetail(erpInventoryTransferDetail));
    }

    /**
     * 修改调拨明细管理
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:edit')")
    @Log(title = "调拨明细管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpInventoryTransferDetail erpInventoryTransferDetail)
    {
        return toAjax(erpInventoryTransferDetailService.updateErpInventoryTransferDetail(erpInventoryTransferDetail));
    }

    /**
     * 删除调拨明细管理
     */
    @PreAuthorize("@ss.hasPermi('storage:allotDetail:remove')")
    @Log(title = "调拨明细管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpInventoryTransferDetailService.deleteErpInventoryTransferDetailByIds(ids));
    }
}
